/*
 * BanBu_EmoViewCell
 * @description 本文件提供聊天界面对话界面显示表情消息的cell
 * @package
 * @author 		***
 * @copyright
 * @version 		1.0
 * @description 本文件提供聊天界面对话界面显示表情消息的cell
 */

#import "BanBu_EmoViewCell.h"
#import "BanBuAPIs.h"
#import "AppDataManager.h"
#import "ASIHTTPRequest.h"

@implementation BanBu_EmoViewCell
-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        _gifView = [[SCGIFImageView alloc]initWithFrame:CGRectZero];
        self.backgroundColor = [UIColor clearColor];
        [self.contentView addSubview:_gifView];
        
    }
    return self;
}

-(void)dealloc
{
    [_gifView release];
    _gifView = nil;
    [super dealloc];
}

-(void)layoutSubviews
{
    //设置父类
    [super layoutSubviews];
    float height = self.contentView.frame.size.height;
    self.bkView.alpha = 0;
    self.bkView.frame = BKViewRect00(self.bkViewWidth, height-5);
    
    //    _gifView.frame = MediaViewRect02;
    
    if (!self.atLeft)
    {
        _gifView.frame = CGRectMake(self.bkView.frame.origin.x + 10, self.bkView.frame.origin.y + 10, self.bkView.frame.size.width - 20, self.bkView.frame.size.height - 20);
        CGRect frame = self.statusView.frame;
        frame.origin.x -= 15;
        
        self.statusView.frame = frame;
    }
    else
    {
        _gifView.frame = CGRectMake(self.bkView.frame.origin.x, self.bkView.frame.origin.y, self.bkView.frame.size.width - 20, self.bkView.frame.size.height - 20);
    }
    self.avatar.frame = AvatarRect02;

//    [self.vipImageView setFrame:CGRectMake(self.avatar.frame.origin.x + 28, self.avatar.frame.origin.y + 26, 15, 10)];
}

//设置cell的各种信息
-(void)setChatCellInfo:(NSDictionary *)amsg
{
    //设置父类的属性
    [super setChatCellInfo:amsg];
    
    [self setEmi:[amsg valueForKey:KeyContent]];
}

//设置webView显示GIF动画
-(void)setEmi:(NSString *)gifPath
{
    NSString * path = [[NSBundle mainBundle]  pathForResource:gifPath ofType:@"gif"];
    _gifView.gifData = [NSData dataWithContentsOfFile:path];
    UIImage * image = [UIImage imageWithContentsOfFile:path];
    self.bkViewWidth = image.size.width;
    float height = self.contentView.frame.size.height;
    self.bkView.alpha = 0;
    self.bkView.frame = BKViewRect00(self.bkViewWidth, height-5);
    
//    _gifView.frame = MediaViewRect02;
    _gifView.frame = CGRectMake(self.bkView.frame.origin.x, self.bkView.frame.origin.y, self.bkView.frame.size.width - 20, self.bkView.frame.size.height - 20);
    if (!self.atLeft)
    {
        CGRect frame = self.statusView.frame;
        frame.origin.x -= 15;
        
        self.statusView.frame = frame;
    }

    self.avatar.frame = AvatarRect02;
 }

@end
